package com.lin.processor;

import com.lin.entity.Impl.PersonDaoImpl;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;

public class MyBeanPostProcessor implements BeanPostProcessor {
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        if (bean instanceof PersonDaoImpl personDaoImpl) {
            personDaoImpl.setName("lin");
        }
        System.out.println("postProcessBeforeInitialization 执行");
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("postProcessAfterInitialization 执行");
        return bean;
    }
}
